import CameraPoseProxy from "./CameraPoseProxy"
import CameraModule from "./module/CameraModule"
import OpenDeferred from "./utils/OpenDeferred"
export default class ControllerProxy {
  proxy: CameraPoseProxy
  target: CameraModule
  constructor(proxy: CameraPoseProxy, target: CameraModule) {
    this.proxy = proxy
    this.target = target
  }
  beginExternalTransition() {
    this.proxy.activeSession(this) && this.target.beginExternalTransition()
  }
  endExternalTransition() {
    this.proxy.activeSession(this) && this.target.endExternalTransition()
  }
  updateCameraPosition(e: THREE.Vector3) {
    this.proxy.activeSession(this) && this.target.updateCameraPosition(e)
  }
  updateCameraRotation(e: THREE.Vector3) {
    this.proxy.activeSession(this) && this.target.updateCameraRotation(e)
  }
  updateCameraFocus(e: number) {
    this.proxy.activeSession(this) && this.target.updateCameraFocus(e)
  }
  moveTo(e) {
    return this.proxy.activeSession(this) ? this.target.moveTo(e) : OpenDeferred.resolve()
  }
}
